﻿using System.Linq;
using LoungeRepo.Contracts.EntityStore;
using LoungeRepo.Contracts.Normalizer;
using LoungeRepo.Serialization;
using NUnit.Framework;

namespace Test.LoungeRepo.Serialization
{
    [TestFixture]
    public class testBinarySerializer
    {
        [Test]
        public void Serialize_and_deserialize()
        {
            INormalizedEntity entity = new SomeNormalizedEntity {Id = "1", Partition = "p"};
            var sut = new BinarySerializer();

            IStreamedEntity stream = sut.Serialize(entity);
            stream.Blob.Seek(0, System.IO.SeekOrigin.Begin);
            INormalizedEntity entity2 = sut.Deserialize(stream);

            Assert.AreEqual(entity.Id, entity2.Id);
            Assert.AreEqual(entity.Fields.First().Value, entity2.Fields.First().Value);
        }
    }
}
